<template>
  <div class="login-wrap">
    <el-card class="login-card">
      <h2>登录</h2>
      <el-form @submit.prevent="handleLogin">
        <el-form-item>
          <el-input v-model="form.username" placeholder="用户名" />
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="form.password"
            type="password"
            placeholder="密码"
          />
        </el-form-item>
        <el-button type="primary" native-type="submit" style="width: 100%">
          登录
        </el-button>
      </el-form>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { reactive } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const form = reactive({ username: '', password: '' })

const handleLogin = () => {
  // 仅演示：任意账号密码直接进后台
  localStorage.setItem('token', 'demo-token')
  router.replace('/')
}
</script>

<style scoped>
.login-wrap {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f3f3;
}
.login-card {
  width: 360px;
  padding: 24px;
}
</style>
